<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //   创建promise的实例 

        const p1 = new Promise((resolve,reject)=>{
            try{
                console.log('获取数据a');
                // 设置定时器模拟ajax
                setTimeout(()=>{
                    console.log('获取a数据成功');
                    resolve({
                        age:18
                    })
                },2000)
            }catch(e){
                console.log(e.message);
            }
        })

      const p2 = p1.finally((reason)=>{
                return new Promise((resolve,reject)=>{
                    // resolve('成功')
                   reject("失败")
                })
      })

          console.log(p2, 'p2');
    </script>

</body>
</html>